{% extends 'admin/base.html' %}

{%load comm_extras %}

{% block head_soruce %}
<script type="text/javascript">
	var selUrl = '{%url admin-hotproduct-add 88888888 %}';

	function selProduct(itemId){
		if(!confirm('你确定要添加吗？')){return;}
		var url = selUrl.replace('88888888', itemId);
		$.ajax({
			url: url,
			type: 'get',
			dataType: 'json',
			success: function(result, textStatus){
				if(result){
					if(result.success){
						alert('添加成功');
					}else{
						alert(result.err_msg);
					}
				}else{
					alert('添加失败');
				}
			},
			error: function(xhr, textStatus, errorThrown){
			}
		});
	}

	function search(){
		var url = '{%url admin-hotproduct-select%}';
		var keyword = '?keyword=' + $('#txtSearch').val();
		window.location.href = url + keyword;
	}

</script>
{% endblock %}

{% block main_content %}
	<h1>添加推荐产品--<a href="{%url admin-hotproduct-index %}">返回推荐商品管理</a></h1>
	<input type="text" id="txtSearch"/><input type="button" value="搜索后选择商品" onclick="search();"/>
	<ul id="movie-form" class="form">
	{%for item in items %}
		<li>
			<img src="/static/productimgs/{{item.homeimage.thumburl}}" width="50" height="50" alt="{{item.title}}" />
			<a href="javascript:void(0)" onclick="selProduct({{item.id}});">选择</a>
			<a target="_blank" href="{%url product-detail-info item.id%}">{{item.title}}</a>
		</li>
	{%endfor%}
	</ul>
{% endblock %}
